<template>
  <div>
    <!-- 管理员内容区 -->
    <div class="app-container home" v-show="ifAdmin">
      <div>
<!--        <el-button type="success" style="height: 50px;width: 150px;">剩余车位数：{{spaceInfo.freeSpaceNum}}</el-button>-->
<!--        <el-button type="success"style="height: 50px;width: 150px;">车位总数：{{spaceInfo.totalNum}}</el-button>-->
        <el-button type="primary" plain style="height: 50px;width: 150px;">今日总车流量：{{income.totalTraffic}}</el-button>
        <el-button type="info" plain style="height: 50px;width: 150px;">进场总数：{{income.inNum}}</el-button>
        <el-button type="warning" plain style="height: 50px;width: 150px;">出场总数：{{income.outNum}}</el-button>
        <el-button type="danger" plain style="height: 50px;width: 200px;">危险化学品车辆：{{income.danger}}</el-button>
        <el-button type="success" plain style="height: 50px;width: 200px;">货物运输车辆：{{income.goods}}</el-button>
        <el-button type="success" plain style="height: 50px;width: 200px;">工作人员车辆：{{income.worker}}</el-button>
        <el-button type="success" plain style="height: 50px;width: 150px;">临时车辆：{{income.temporary}}</el-button>
        <el-button type="info" plain style="height: 50px;width: 150px;">其他车辆：{{income.orther}}</el-button>
      </div>
      <hr/>
      <el-row :gutter="15">
            <el-col :span="16">
                <el-col :span="24">
                  <el-card class="update-log">
                    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="80px" style="height: 30px;">
                      <el-form-item label="车牌号码" prop="plateNo">
                        <el-input
                          v-model="queryParams.plateNo"
                          placeholder="请输入车牌号码"
                          clearable
                          style="width: 160px"
                          @keyup.enter.native="handleQuery"
                        />
                      </el-form-item>
                      <el-form-item label="开始日期">
                        <el-date-picker clearable
                                        v-model="queryParams.startTime"
                                        type="date"
                                        value-format="yyyy-MM-dd"
                                        style="width: 160px"
                                        placeholder="请选择开始日期">
                        </el-date-picker>
                      </el-form-item>
                      <el-form-item label="结束日期">
                        <el-date-picker clearable
                                        v-model="queryParams.endTime"
                                        type="date"
                                        value-format="yyyy-MM-dd"
                                        style="width: 160px"
                                        placeholder="请选择结束日期">
                        </el-date-picker>
                      </el-form-item>
                      <el-form-item>
                        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
                      </el-form-item>
                    </el-form>
                  </el-card>
                </el-col>
                <el-col :span="24">
                  <el-card class="update-log">
                    <el-table v-loading="loading" :data="dataList">
                      <el-table-column label="序号" fixed align="center" width="50">
                        <template scope="scope">
                          <span>{{(queryParams.pageIndex-1)*queryParams.pageSize+(scope.$index + 1)}} </span>
                        </template>
                      </el-table-column>
                      <el-table-column label="车牌号码" align="center" prop="plate_no"/>
                      <el-table-column label="驾驶员" align="center" prop="drive_name"/>
                      <el-table-column label="驾驶证号" align="center" prop="drive_card_id"/>
                      <el-table-column label="危险货物运输证" align="center" prop="danger_card_id"/>
                      <el-table-column label="运输货物" align="center" prop="freight"/>
                      <el-table-column label="登记单位" align="center" prop="car_company"/>
                      <el-table-column label="图片" align="center" prop="imgName">
                        <template slot-scope="scope" style="display: flex;">
                          <el-image :src="scope.row.imgName" :preview-src-list="[scope.row.imgName]" style="width: 100px;height: 60px" />
                        </template>
                      </el-table-column>
                      <el-table-column label="入口" align="center" prop="entry_place"/>
                      <el-table-column label="进场时间" align="center" prop="entry_time" width="150">
                        <template slot-scope="scope">
                          <span>{{ parseTime(scope.row.entry_time,'{y}-{m}-{d} {h}:{i}') }}</span>
                        </template>
                      </el-table-column>
                    </el-table>

                    <pagination
                      v-show="total>0"
                      :total="total"
                      :page.sync="queryParams.pageIndex"
                      :limit.sync="queryParams.pageSize"
                      @pagination="getTransfer"
                    />
                  </el-card>
                </el-col>
            </el-col>
            <el-col :span="8">
              <el-card class="update-log" style="min-height: 800px" body-style="font-size: 25px">
                <el-link type="primary" style="font-size: 16px">今日预约车次：{{reportParams.total}}次</el-link><br>
<!--                <el-link type="success" style="padding-right: 30px;font-size: 16px">已进场：0辆</el-link><br>-->
<!--                <el-link type="info" style="padding-right: 30px;font-size: 16px">已离场：0辆</el-link><br>-->
                <hr/>
                <el-table :data="reportList">
                  <el-table-column label="序号" fixed align="center" width="50">
                    <template scope="scope">
                      <span>{{(reportParams.pageNum-1)*reportParams.pageSize+(scope.$index + 1)}} </span>
                    </template>
                  </el-table-column>
                  <el-table-column label="车牌号码" align="center" prop="carNumber" width="100"/>
                  <el-table-column label="出发地" align="center" prop="originPlace" width="180">
                    <template slot-scope="scope">
                      <span>{{(scope.row.originPlace+"").split("|")[1] }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="疫情政策" align="center" prop="policy">
                    <template slot-scope="scope">
                      <el-button
                        size="mini"
                        type="text"
                        icon="el-icon-edit"
                        @click="handleOpen(scope.row)"
                      >查看疫情政策</el-button>
                    </template>
                  </el-table-column>
                </el-table>
                <pagination
                  v-show="reportParams.total>0"
                  :total="reportParams.total"
                  :page.sync="reportParams.pageNum"
                  :limit.sync="reportParams.pageSize"
                  @pagination="getReportList"
                />
              </el-card>
            </el-col>
      </el-row>

      <el-dialog title="出发地疫情政策" :visible.sync="openPolicy" width="600px" append-to-body>
        <span v-html="policy"></span>
      </el-dialog>

    </div>

    <!-- 企业内容区 -->
    <div class="app-container home" v-show="ifOrg">
      <div>
        <el-button type="success" style="height: 50px;width: 200px;">今日申请总数：{{orgParams.total}}</el-button>
<!--        <el-button type="primary" plain style="height: 50px;width: 150px;">待审核：{{income.totalTraffic}}</el-button>-->
<!--        <el-button type="info" plain style="height: 50px;width: 150px;">已通过：{{income.inNum}}</el-button>-->
<!--        <el-button type="warning" plain style="height: 50px;width: 150px;">未通过：{{income.outNum}}</el-button>-->
      </div>
      <hr/>
      <el-card class="update-log">
        <el-form :model="orgParams" ref="queryForm" size="small" :inline="true" label-width="68px">
          <el-form-item label="驾驶员" prop="driveName">
            <el-input
              v-model="orgParams.driveName"
              placeholder="请输入驾驶员"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="车牌号" prop="carNumber">
            <el-input
              v-model="orgParams.carNumber"
              placeholder="请输入车牌号"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQueryOrg">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQueryOrg">重置</el-button>
          </el-form-item>
        </el-form>
      </el-card>
      <el-card class="update-log">
        <el-table v-loading="loading" :data="infoList">
          <el-table-column label="序号" width="55" align="center" prop="serialNumber"/>
          <el-table-column label="驾驶员" align="center" prop="driveName"/>
          <el-table-column label="车牌号" align="center" prop="carNumber"/>
          <el-table-column label="出发地" align="center" prop="originPlace">
            <template slot-scope="scope">
              <span>{{(scope.row.originPlace+"").split("|")[1] }}</span>
            </template>
          </el-table-column>
          <el-table-column label="进场日期" align="center" prop="comeTime">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.comeTime, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="离场日期" align="center" prop="outTime">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.outTime, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="发货单位" align="center" prop="forwardingUnit"/>
          <el-table-column label="收货单位" align="center" prop="receivingUnit"/>
          <el-table-column label="申请时间" align="center" prop="createTime"/>
          <el-table-column label="审核状态" align="center" prop="createTime">
            <template slot-scope="scope">
              <span v-if="scope.row.state == '0'">待审核</span>
              <span v-if="scope.row.state == '1'">已通过</span>
              <span v-if="scope.row.state == '2'">未通过</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200" fixed="right">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-search"
                @click="handleShow(scope.row)"
              > 查看政策
              </el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-search"
                @click="detail(scope.row)"
              > 详情
              </el-button>
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="orgParams.total>0"
          :total="orgParams.total"
          :page.sync="orgParams.pageNum"
          :limit.sync="orgParams.pageSize"
          @pagination="getList"
        />
      </el-card>


      <!-- 添加或修改预约记录对话框 -->
      <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
        <el-form ref="form" :model="form" label-width="100px">
          <template v-if="form.reportType == 'worker'">
            <el-form-item label="审核状态" prop="state" v-show="false">
              <el-input v-model="form.state" placeholder="无" :readonly="true"/>
            </el-form-item>
            <div class="barrier">
              <el-form-item label="登记单位" prop="company">
                <el-input v-model="form.company" placeholder="无" :readonly="true"/>
              </el-form-item>
              <el-form-item label="通行时间" prop="passLoadTime">
                <el-input v-model="form.comeTime + ' ~ '+ form.outTime" placeholder="无" :readonly="true"/>
              </el-form-item>
            </div>
            <div class="barrier">
              <el-form-item label="驾驶员" prop="driveName">
                <el-input v-model="form.driveName" placeholder="无" :readonly="true"/>
              </el-form-item>
              <el-form-item label="部门及职务" prop="department">
                <el-input v-model="form.department" placeholder="无" :readonly="true"/>
              </el-form-item>
            </div>
            <div class="barrier">
              <el-form-item label="联系电话" prop="phone">
                <el-input v-model="form.phone" placeholder="无" :readonly="true"/>
              </el-form-item>
              <el-form-item label="车辆型号" prop="carType">
                <el-input v-model="form.carType" placeholder="无" :readonly="true"/>
              </el-form-item>
            </div>
            <div class="barrier">
              <el-form-item label="车牌号" prop="carNumber">
                <el-input v-model="form.carNumber" placeholder="无" :readonly="true"/>
              </el-form-item>
              <el-form-item label="驾驶证号" prop="driveCardId">
                <el-input v-model="form.driveCardId" placeholder="无" :readonly="true"/>
              </el-form-item>
            </div>
            <div class="barrier">
              <el-form-item label="行驶证" prop="drivingLicenseCard">
                <el-input v-model="form.drivingLicenseCard" placeholder="无" :readonly="true"/>
              </el-form-item>
              <el-form-item label="通行期限" prop="passLoadTime">
                <el-input v-model="form.passLoadTime" placeholder="无" :readonly="true"/>
              </el-form-item>
            </div>
          </template>

          <template v-if="form.reportType == 'goods'">
            <div class="barrier">
              <el-form-item label="登记单位" prop="company">
                <el-input v-model="form.company" placeholder="无" :readonly="true"/>
              </el-form-item>
              <el-form-item label="通行时间" prop="passLoadTime">
                <el-input v-model="form.comeTime + ' ~ '+ form.outTime" placeholder="无" :readonly="true"/>
              </el-form-item>
            </div>
            <div class="barrier">
              <el-form-item label="驾驶员" prop="driveName">
                <el-input v-model="form.driveName" placeholder="无" :readonly="true"/>
              </el-form-item>
              <el-form-item label="联系电话" prop="phone">
                <el-input v-model="form.phone" placeholder="无" :readonly="true"/>
              </el-form-item>
            </div>
            <div class="barrier">
              <el-form-item label="车牌号" prop="carNumber">
                <el-input v-model="form.carNumber" placeholder="无" :readonly="true"/>
              </el-form-item>
              <el-form-item label="挂车号" prop="trailerCardId">
                <el-input v-model="form.trailerCardId" placeholder="无" :readonly="true"/>
              </el-form-item>
            </div>
            <div class="barrier">
              <el-form-item label="驾驶证号" prop="driveCardId">
                <el-input v-model="form.driveCardId" placeholder="无" :readonly="true"/>
              </el-form-item>
              <el-form-item label="行驶证" prop="drivingLicenseCard">
                <el-input v-model="form.drivingLicenseCard" placeholder="无" :readonly="true"/>
              </el-form-item>
            </div>
            <div class="barrier">
              <el-form-item label="运输货物" prop="freight">
                <el-input v-model="form.freight" placeholder="无" :readonly="true"/>
              </el-form-item>
              <el-form-item label="车辆最大载重" prop="maxLoad">
                <el-input v-model="form.maxLoad" placeholder="无" :readonly="true"/>
              </el-form-item>
            </div>
            <div class="barrier">
              <el-form-item label="车辆所属公司" prop="carCompany">
                <el-input v-model="form.carCompany" placeholder="无" :readonly="true"/>
              </el-form-item>
              <el-form-item label="出发地与通行路线" prop="trafficRoute">
                <el-input v-model="form.originPlace + '|' + form.trafficRoute" placeholder="无" :readonly="true"/>
              </el-form-item>
            </div>
            <div class="barrier">
              <el-form-item label="发货单位" prop="forwardingUnit">
                <el-input v-model="form.forwardingUnit" placeholder="无" :readonly="true"/>
              </el-form-item>
              <el-form-item label="收货单位" prop="receivingUnit">
                <el-input v-model="form.receivingUnit" placeholder="无" :readonly="true"/>
              </el-form-item>
            </div>
          </template>


          <template v-if="form.reportType == 'temporary'">
            <div class="barrier">
              <el-form-item label="登记单位" prop="company">
                <el-input v-model="form.company" placeholder="无" :readonly="true"/>
              </el-form-item>
              <el-form-item label="驾驶员" prop="driveName">
                <el-input v-model="form.driveName" placeholder="无" :readonly="true"/>
              </el-form-item>
            </div>
            <div class="barrier">
              <el-form-item label="车牌号" prop="carNumber">
                <el-input v-model="form.carNumber" placeholder="无" :readonly="true"/>
              </el-form-item>
              <el-form-item label="挂车号" prop="trailerCardId">
                <el-input v-model="form.trailerCardId" placeholder="无" :readonly="true"/>
              </el-form-item>
            </div>
            <div class="barrier">
              <el-form-item label="驾驶证号" prop="driveCardId">
                <el-input v-model="form.driveCardId" placeholder="无" :readonly="true"/>
              </el-form-item>
              <el-form-item label="车辆所属公司" prop="carCompany">
                <el-input v-model="form.carCompany" placeholder="无" :readonly="true"/>
              </el-form-item>
            </div>
            <div class="barrier">
              <el-form-item label="车辆型号" prop="carType">
                <el-input v-model="form.carType" placeholder="无" :readonly="true"/>
              </el-form-item>
              <el-form-item label="出发地与通行路线" prop="trafficRoute">
                <el-input v-model="form.originPlace + '|' + form.trafficRoute" placeholder="无" :readonly="true"/>
              </el-form-item>
            </div>
            <div class="barrier">
              <el-form-item label="事由">
                <el-input v-model="form.mainContent" type="textarea" placeholder="无" :readonly="true"/>
              </el-form-item>
              <el-form-item label="同行人员" prop="peerPersonnel">
                <el-input v-model="form.peerPersonnel" placeholder="无" :readonly="true"/>
              </el-form-item>
            </div>
          </template>

          <template v-if="form.reportType == 'danger' || form.reportType == null">
            <el-row>
              <el-col :span="24">
                <el-form-item label="登记单位" prop="company">
                  <el-input v-model="form.company" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="进场日期" prop="comeTime">
                  <el-input v-model="form.comeTime" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="离场日期" prop="outTime">
                  <el-input v-model="form.outTime" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="通行时间" prop="passLoadTime">
                  <el-input v-model="form.comeTime + ' ~ '+ form.outTime" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="驾驶员" prop="driveName">
                  <el-input v-model="form.driveName" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="驾驶证号" prop="driveCardId">
                  <el-input v-model="form.driveCardId" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="押运员" prop="escortName">
                  <el-input v-model="form.escortName" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="押运员证号" prop="escortCardId">
                  <el-input v-model="form.escortCardId" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="车牌号" prop="carNumber">
                  <el-input v-model="form.carNumber" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="行驶证" prop="drivingLicenseCard">
                  <el-input v-model="form.drivingLicenseCard" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="挂车号" prop="trailerCardId">
                  <el-input v-model="form.trailerCardId" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="危险货物运输证" prop="dangerCardId">
                  <el-input v-model="form.dangerCardId" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="车辆最大载重" prop="maxLoad">
                  <el-input v-model="form.maxLoad" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="车辆所属公司" prop="carCompany">
                  <el-input v-model="form.carCompany" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>

              <el-col :span="12">
                <el-form-item label="发货单位" prop="forwardingUnit">
                  <el-input v-model="form.forwardingUnit" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="收货单位" prop="receivingUnit">
                  <el-input v-model="form.receivingUnit" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="出发地" prop="originPlace">
                  <el-input v-model="form.originPlace" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="运输货物" prop="freight">
                  <el-input v-model="form.freight" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="通行路线" prop="trafficRoute">
                  <el-input v-model="form.trafficRoute" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="审核时间" prop="examineTime">
                  <el-input v-model="form.examineTime" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="审核意见" prop="examineOpinion">
                  <el-input v-model="form.examineOpinion" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="备注" prop="remarks">
                  <el-input v-model="form.remarks" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="申请人" prop="loginId">
                  <el-input v-model="form.loginId" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="联系电话" prop="phone">
                  <el-input v-model="form.phone" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="申请方式" prop="hpage">
                  <el-input value="H5" v-if="form.hpage==1" placeholder="" :readonly="true"/>
                  <el-input value="APP" v-if="form.hpage==0" placeholder="" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="最后入场时间" prop="keepTime">
                  <el-input v-model="form.keepTime" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="所属单位" prop="unitName">
                  <el-input v-model="form.unitName" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="部门及职务" prop="department">
                  <el-input v-model="form.department" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="事由">
                  <el-input v-model="form.mainContent" type="textarea" :autosize="{ minRows: 3, maxRows: 5}" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="同行人员" prop="peerPersonnel">
                  <el-input v-model="form.peerPersonnel" placeholder="无" :readonly="true"/>
                </el-form-item>
              </el-col>
              <el-form-item label="政策" prop="policy" class="gelan">
                <el-input v-model="form.policy" type="textarea" :autosize="{ minRows: 5, maxRows: 8}" placeholder="无" :readonly="true"/>
              </el-form-item>
              <el-form-item label="停用原因" prop="reasonDeactivation" class="gelan">
                <el-input v-model="form.reasonDeactivation" type="textarea" placeholder="无" :readonly="true"/>
              </el-form-item>
            </el-row>
          </template>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="cancel">关闭</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
  import { clientUrl } from "@/api/client";
  import { getReportList } from "@/api/index";
  import { getInfo } from '@/api/login'
  import { orgReportlist,getInfo as reportInfo} from "@/api/system/info"
  import { listEntrylog, getCountData } from "@/api/system/entrylog";

  export default {
    name: "Index",
    dicts: ['cap_flag', 'car_type','car_style','pass_type'],
    data() {
      return {
        // 遮罩层
        loading: true,
        // 是否显示弹出层
        open: false,
        openPolicy:false,
        title:"",
        // 日期范围
        dateRange:[],
        spaceInfo:{},
        hourReport:[],
        incomeList:[],
        income:{
          // 总车流量
          totalTraffic: 0,
          // 进场总数
          inNum: 0,
          // 出场总数
          outNum: 0,
          // 分类
          danger: 0,
          goods: 0,
          temporary: 0,
          worker: 0,
          orther:0,
        },
        payDetailList:[],
        nodeList:[],
        data_x:[],
        data_y:[],
        // 车位查询参数
        spaceParams: {
          url:'/api/wec/GetFreeSpaceNum',
          serviceCode: 'getFreeSpaceNum',
        },
        // 道闸查询参数
        nodeParams: {
          url:'/api/wec/GetParkingNodeStatus',
          serviceCode: 'getParkingNodeStatus',
        },
        // 收入查询参数
        incomeParams: {
          url:'/api/wec/GetParkingFlowReport',
          serviceCode: 'getParkingFlowReport',
          startTime:this.appendFix(this.parseTime(new Date(),'{y}-{m}-{d}'),1),
          endTime:this.appendFix(this.parseTime(new Date(),'{y}-{m}-{d}'),2),
        },
        pay_title:'支付方式',

        //列表
        dataList:[],
        // 总条数
        total: 0,
        // // 查询参数
        // queryParams: {
        //   url:'/api/wec/GetCarInoutInfo',
        //   pageIndex: 1,
        //   pageSize: 10,
        //   serviceCode: 'getCarInoutInfo',
        //   plateNo:'',
        //   cardNo:'',
        //   startTime:this.appendFix(this.parseTime(new Date(),'{y}-{m}-{d}'),1),
        //   endTime:this.appendFix(this.parseTime(new Date(),'{y}-{m}-{d}'),2),
        //   capFlag:''
        // },

        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          plateNo: null,
          startTime: null,
          endTime: null,
          reportType: "danger",
        },

        // 查询参数
        countDataParams: {
          entryTime: this.parseTime(new Date(),'{y}-{m}-{d}')
        },

        countData:{},

        reportParams:{
          total: 0,
          pageNum:1,
          pageSize: 10,
          createTime:this.appendFix(this.parseTime(new Date(),'{y}-{m}-{d}'),1),
        },
        reportList:[],
        policy:'',


        ifAdmin:false,
        ifOrg:false,

        infoList:[],
        orgParams:{
          total: 0,
          pageNum: 1,
          pageSize: 10,
          carNumber: null,
          driveName: null,
          createTime:this.appendFix(this.parseTime(new Date(),'{y}-{m}-{d}'),1),
        },

        // 表单参数
        form: {},
      };
  },

  methods: {
    // getSpaceInfo(){
    //   clientUrl(this.spaceParams).then(response => {
    //     this.spaceInfo = JSON.parse(response.data.data)
    //   });
    // },

    getCountData(){
      getCountData(this.countDataParams).then(response => {
        this.incomeList = response
        this.incomeList.forEach(item=>{
          if(item.report_type == 'danger'){
            this.income.danger = item.num
          }else if(item.report_type == 'goods'){
            this.income.goods = item.num
          }else if(item.report_type == 'temporary'){
            this.income.temporary = item.num
          }else if(item.report_type == 'worker'){
            this.income.worker = item.num
          }else{
            this.income.orther = item.num
          }
        })
      });
    },

    getNodeList(){
      clientUrl(this.nodeParams).then(response => {
        let data = JSON.parse(response.data.data)
        this.nodeList = data.nodeList
      });
    },

    getIncome(){
      let dict = [];
      this.getDicts('pay_type').then(response => {
        dict =  response.data;
      });
      clientUrl(this.incomeParams).then(response => {
        let data = JSON.parse(response.data.data);
        data.payDetailList.forEach(item => {
          let obj = {}
            dict.forEach(item2 => {
              if(item2.dictValue == item.payMethod){
                obj.name = item2.dictLabel;
              }
            });
          obj.value = item.payTotalMoney/100;
          this.payDetailList.push(obj)
        });
        this.income.totalTraffic = parseInt(data.totalTraffic);
        this.income.inNum = parseInt(data.inNum);
        this.income.outNum = parseInt(data.outNum);
        // this.income.totalPay = parseInt(data.totalPay);
        // this.income.totalMoney = parseInt(data.totalMoney);
        // this.income.ticketMoney = parseInt(data.ticketMoney);
        // this.income.ticketTime = parseInt(data.ticketTime);
      });
    },

    getTransfer(){
      this.loading = true;

      // clientUrl(this.queryParams).then(response => {
      //   let data = JSON.parse(response.data.data)
      //   this.dataList = data.detailList;
      //   this.total = parseInt(data.totalCount);
      //   this.loading = false;
      // });

      listEntrylog(this.queryParams).then(response => {
        this.dataList = response.rows;
        this.total = response.total;
        this.loading = false;
      });

    },

    getReportList(){
      getReportList(this.reportParams).then(response => {
        this.reportList = response.rows;
        this.reportParams.total = response.total;
      });
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageIndex = 1;
      this.getTransfer();
    },

    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.plateNo = '';
      this.queryParams.cardNo = '';
      this.queryParams.capFlag = '';
      this.handleQuery();
    },

    /** 搜索按钮操作 */
    handleQueryOrg() {
      this.orgParams.pageNum = 1;
      this.getList();
    },

    /** 重置按钮操作 */
    resetQueryOrg() {
      this.resetForm("queryForm");
      this.orgParams.carNumber = '';
      this.orgParams.driveName = '';
      this.handleQueryOrg();
    },

    /** 查看疫情政策 */
    handleOpen(row) {
      this.policy = row.policy
      this.openPolicy = true;
    },

    /** 关闭疫情政策 */
    handleClose() {
      this.openPolicy = false;
    },

    getUser(){
      getInfo().then(response => {
        let data = response.roles
        if(data.indexOf("admin") > -1 || data.indexOf("index") > -1){
          this.ifAdmin = true;
        }else{
          this.ifOrg = true;
        }
      })
    },

    getList() {
      this.loading = true;
      orgReportlist(this.orgParams).then(response => {
        this.infoList = response.rows;
        this.orgParams.total = response.total;
        this.loading = false;
      });
    },

    handleShow(row){
      console.log(row.policy);
      this.$alert(row.policy, '疫情政策', {
        dangerouslyUseHTMLString: true,
        confirmButtonText: '确定',
        callback: action => {

        }
      });
    },

    detail(row){
      const id = row.id
      reportInfo(id).then(response => {
        this.form = response.data;
        this.open = true;
        if(this.form.reportType == 'danger'){
          this.title = "危化品车辆申请";
        }else if(this.form.reportType == 'worker'){
          this.title = "工作人员车辆申请";
        }else if(this.form.reportType == 'goods'){
          this.title = "货物运输车辆申请";
        }else if(this.form.reportType == 'temporary'){
          this.title = "临时车辆申请";
        }else {
          this.title = "其他预约";
        }
      });
    },

    // 取消按钮
    cancel() {
      this.open = false;
    },

  },

  created() {
      this.getUser();
      this.getList();
  },


   mounted() {
    // this.getSpaceInfo();
    // setInterval(() => {
    //   setTimeout(this.getSpaceInfo, 0)
    // }, 1000 * 60 * 5);

    this.getIncome();
    setInterval(() => {
      setTimeout(this.getIncome, 0)
    }, 1000 * 60 * 5);

    this.getTransfer();
    setInterval(() => {
      setTimeout(this.getTransfer, 0)
    }, 1000 * 60 * 5)

    this.getReportList();
    setInterval(() => {
      setTimeout(this.getReportList, 0)
    }, 1000 * 60 * 5)

     this.getCountData();
     setInterval(() => {
       setTimeout(this.getCountData, 0)
     }, 1000 * 60 * 5)
  }
};
</script>

<style scoped lang="scss">
.home {
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #dadada;
  }
  .col-item {
    margin-bottom: 20px;
  }
  ul {
    padding: 0;
    margin: 0;
  }
  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;
  ul {
    list-style-type: none;
  }
  h4 {
    margin-top: 0px;
  }
  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }
  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }
  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }

    margin-bottom: 10px;
  }
  .gate_css{
    line-height: 40px;
  }
  .pie_msg{
    padding: 10px 0px;
  }
  .pie_msg span{
    margin-right: 10px;
  }

}
</style>

